package cn.itcast.service.system;

import cn.itcast.domain.system.Module;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.shiro.crypto.hash.Md5Hash;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import sun.security.provider.MD5;

import java.util.*;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath*:spring/applicationContext-*.xml")
public class test {

    @Test
    public void test() throws Exception {
        ObjectMapper objectMapper = new ObjectMapper();
        cn.itcast.domain.system.Module module = new cn.itcast.domain.system.Module();
        module.setId("1");
        module.setBelong(1);
        module.setCpermission("51654");
        module.setCtype(1);
        module.setCurl("5165465");
        module.setName("ajdnjakdn");
        List<Module> modules = new ArrayList<>();
        modules.add(module);
        String s = objectMapper.writeValueAsString(modules);

        JavaType javaType = objectMapper.getTypeFactory().constructParametricType(List.class, Module.class);
        List<Module> moduleList = objectMapper.readValue(s, javaType);
        for (Module module1 : moduleList) {
            System.out.println(module1);
            System.out.println(module1.getName());
        }

    }


    @Test
    public void asas(){
        String s = new Md5Hash("1", "lz@163.com").toString();
        System.out.println(s);
    }
    }
